package com.game.simplegame.creature;

import com.game.simplegame.world.World;

/**
 * Created by Administrator on 2017-04-18.
 */
public class SleepStatus implements ICreatureStatus {

    long wakeUpTime;

    @Override
    public void update(long dtSec, Creature creature,World world) {
        System.out.println("sleeping");
        creature.addEnergy(creature.getSleepEnergyCost());
        if(world.getTimeInSecond() > wakeUpTime){
            creature.changeTo(new GotoEatStatus());
        }
    }

    @Override
    public void onDisActive(Creature creature,World world) {

    }

    @Override
    public void onActive(Creature creature,World world) {
        int sleepHours = 8 + (int)(Math.random() * 2);
        wakeUpTime = world.getTimeInSecond() + sleepHours * 60 * 60;
    }
}
